<template>
  <nav class="navbar navbar-default navigate-main" role="navigation">
    <div class="container-fluid">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse"
                data-target="#example-navbar-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand navigate-title" href="/admin/">
          <i class="el-icon-s-home"></i>医院管理系统</a>
      </div>
      <div class="collapse navbar-collapse" id="example-navbar-collapse">
        <ul class="nav navbar-nav navbar-right">
          <li class="dropdown">
            <a href="#" class="dropdown-toggle navigate-menu" data-toggle="dropdown">{{ adminName }}<b class="caret"></b></a>
            <ul class="dropdown-menu navigate-menu">
              <li><a class="navigate-menu-title" @click="logOut">退出登录</a></li>
            </ul>
          </li>
        </ul>
      </div>
    </div>
  </nav>
</template>

<script>
import api from "@/apis/api"
export default {
  name: "AdminNavigate",
  computed:{
    adminName(){
      return this.$store.state.adminModules.adminInfo.name
    }
  },
  methods:{
    async logOut() {
      const _this = this
      const result = await api.logOut()
      if (result.code === 200){
        _this.$util.successMessage("已退出登录")
        // this.$router.
        _this.$router.push("/admin/login")
      }
    }
  }
}
</script>
